<?

//Enbart köra om ej tidigare fel
if( !isset($_SESSION['error']) ) {
	$name = strtolower($_POST['name']);
	
	// Skapa mailbox, skickatkorg, utkastkorg och spamlåda
	exec('/usr/bin/perl -w /usr/share/uggla/extra/imapcreate -u cyrus -p `cat /etc/cyrus.secret` --auth LOGIN -m '.$name.','.$name.'.Skickat,'.$name.'.Utkast,'.$name.'.Spam localhost');
	// aktivera spamfilter
	exec('/usr/bin/sieveshell --user='.$name.' --authname=cyrus --password=`cat /etc/cyrus.secret` --exec="
put /usr/share/doc/cyrus-common-2.2/ingo
activate ingo" localhost 2> /dev/null > /dev/null');
	// aktivera imap-premunation på boxen Spam
	$file = '/var/lib/cyrus/user/'.substr($name,0,1).'/'.$name.'.sub';
        exec('echo "user.'.$name.'.Sent\t" >> '.$file);
        exec('echo "user.'.$name.'.Drafts\t" >> '.$file);
        exec('echo "user.'.$name.'.Templates\t" >> '.$file);
        exec('echo "user.'.$name.'.Spam\t" >> '.$file);
        exec('echo "user.'.$name.'.Trash\t" >> '.$file);
	exec('chown cyrus.mail '.$file);
	exec('chmod 600 '.$file);
}
?>
